import {
  type RouteRecordRaw,
  createRouter,
  createWebHashHistory,
} from "vue-router";
import NProgress from "nprogress";
import "nprogress/nprogress.css";


export const aboutRouter = {
  name: 'about',
  path: '/about',
  component: () => import('@/views/about/index.vue'),
  meta: {},
} as RouteRecordRaw

const modules: Record<string, any> = import.meta.glob(['./modules/*.ts'], {
    eager: true, // 是否懒加载
});
// 配置路由
const routes: Array<RouteRecordRaw> = [];
  Object.keys(modules).forEach((key) => {
    const module  =  modules[key].default
    routes.push(module)
})
routes.push(aboutRouter);
const router = createRouter({
  history: createWebHashHistory(),
  routes,
});
router.beforeEach(async (_to, _from, next) => {
  NProgress.start();
  next();
});
router.afterEach((_to) => {
  NProgress.done();
});
export default router;
